import { Component, OnInit } from '@angular/core';

/*
  获取路由get传值： 先引入 router模块里的 ActivatedRoute, 然后在构造器里 定义一下
*/
import { ActivatedRoute } from '@angular/router'

@Component({
  selector: 'app-news-detail',
  templateUrl: './news-detail.component.html',
  styleUrls: ['./news-detail.component.scss']
})
export class NewsDetailComponent implements OnInit {

  constructor(public route: ActivatedRoute) { }

  ngOnInit(): void {
    
    console.log(this.route);
    //  get传值在这里
    console.log(this.route.queryParams);  
    // 获取get传值, 异步获取
    // this.route.queryParams.subscribe((data: any) => {
    //   console.log(data);
    //   console.log(data.aid)     
    // })

    // 获取动态路由传值
    this.route.params.subscribe((data: any) => {
      console.log(data);
      console.log(data.aid)     
    })
    
  }

}
